<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="FFmpeg笔记(二), jiodg45的博客">
    <meta name="description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>FFmpeg笔记(二) | jiodg45的博客</title>
    <link rel="icon" type="image/png" href="/jiodg45/favicon.png">

    <link rel="stylesheet" type="text/css" href="/jiodg45/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/jiodg45/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/jiodg45/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/jiodg45/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/jiodg45/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/jiodg45/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/jiodg45/css/my.css">

    <script src="/jiodg45/libs/jquery/jquery.min.js"></script>

<meta name="generator" content="Hexo 5.4.0">
<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
</head>




<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/jiodg45/" class="waves-effect waves-light">
                    
                    <img src="/jiodg45/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">jiodg45的博客</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jiodg45/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jiodg45/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jiodg45/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jiodg45/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jiodg45/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jiodg45/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jiodg45/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/jiodg45/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">jiodg45的博客</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/jiodg45/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jiodg45/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jiodg45/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jiodg45/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jiodg45/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jiodg45/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jiodg45/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/blinkfox/hexo-theme-matery" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/blinkfox/hexo-theme-matery" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/jiodg45/medias/featureimages/12.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">FFmpeg笔记(二)</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/jiodg45/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/jiodg45/tags/audio/">
                                <span class="chip bg-color">audio</span>
                            </a>
                        
                            <a href="/jiodg45/tags/ffmpeg/">
                                <span class="chip bg-color">ffmpeg</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/jiodg45/categories/ffmpeg/" class="post-category">
                                ffmpeg
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2021-03-11
                </div>
                

                

                

                

                
            </div>
        </div>
        <hr class="clearfix">

        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <h2 id="集成FFmpeg"><a href="#集成FFmpeg" class="headerlink" title="集成FFmpeg"></a>集成FFmpeg</h2><p>主要分为量大块,按需将相关的库导入到工程中,补充缺失的头文件</p>
<h2 id="编译FFmpeg"><a href="#编译FFmpeg" class="headerlink" title="编译FFmpeg"></a>编译FFmpeg</h2><p>以iOS为例<br>需要指定平台,Xcode信息,root sdk路径，编译工具链，支持的arch,输出路径，等参数.这里推荐一份完成的脚本,如果自己编译碰到问题可以参考这个脚本<a target="_blank" rel="noopener" href="https://github.com/kewlbear/FFmpeg-iOS-build-script">FFmpeg-iOS-build-script</a></p>
<p>执行<code>./build-ffmpeg.sh</code>,会自动抓去依赖<code>yasm:1.2.0</code>,<code>FFmpeg 4.3.1</code>,<code>gas-preprocessor.pl</code>然后编译生成<code>FFmpeg-iOS </code>文件夹，内容如下：</p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">├── include </span><br><span class="line">│&nbsp;&nbsp; ├── libavcodec    //用于各种类型声音、图像编解码；</span><br><span class="line">│&nbsp;&nbsp; ├── libavdevice   //与系统输入输出设备交互,读取和写入多媒体数据</span><br><span class="line">│&nbsp;&nbsp; ├── libavfilter   //实现滤镜效果，可以用其做一些音视频处理，如音视频倍速、水平翻转、裁剪、加方框、叠加文字等功能。</span><br><span class="line">│&nbsp;&nbsp; ├── libavformat   //用于各种音视频封装格式的生成和解析 </span><br><span class="line">│&nbsp;&nbsp; ├── libavutil     //包含一些公共的工具函数</span><br><span class="line">│&nbsp;&nbsp; ├── libswresample //音频重采样、rematrixing和样本格式转换操作</span><br><span class="line">│&nbsp;&nbsp; └── libswscale    //视频场景比例缩放、色彩映射转换；</span><br><span class="line">└── lib</span><br><span class="line">    ├── libavcodec.a</span><br><span class="line">    ├── libavdevice.a</span><br><span class="line">    ├── libavfilter.a</span><br><span class="line">    ├── libavformat.a</span><br><span class="line">    ├── libavutil.a</span><br><span class="line">    ├── libswresample.a</span><br><span class="line">    └── libswscale.a</span><br></pre></td></tr></tbody></table></figure>

<h2 id="将FFmpeg-iOS集成到iOS工程中"><a href="#将FFmpeg-iOS集成到iOS工程中" class="headerlink" title="将FFmpeg-iOS集成到iOS工程中"></a>将FFmpeg-iOS集成到iOS工程中</h2><p>以Swift项目为例子说明</p>
<p>创建并设置<code>bridge-header.h</code>,设置工程<code>Objective-Bridge-Header</code>的路径</p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">ifndef bridge_h</span></span><br><span class="line"><span class="meta">#</span><span class="bash">define bridge_h</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash">include &lt;libavcodec/avcodec.h&gt;</span></span><br><span class="line"><span class="meta">#</span><span class="bash">include &lt;libavdevice/avdevice.h&gt;</span></span><br><span class="line"><span class="meta">#</span><span class="bash">include &lt;libavfilter/avfilter.h&gt;</span></span><br><span class="line"><span class="meta">#</span><span class="bash">include &lt;libavformat/avformat.h&gt;</span></span><br><span class="line"><span class="meta">#</span><span class="bash">include &lt;libavutil/avutil.h&gt;</span></span><br><span class="line"><span class="meta">#</span><span class="bash">include &lt;libswresample/swresample.h&gt;</span></span><br><span class="line"><span class="meta">#</span><span class="bash">include &lt;libswscale/swscale.h&gt;</span></span><br><span class="line"><span class="meta">#</span><span class="bash">endif /* bridge_h */</span></span><br></pre></td></tr></tbody></table></figure>

<p>设置<code>User Search Path</code></p>
<p>添加依赖库</p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">* libz.dylib</span><br><span class="line">* libbz2.dylib</span><br><span class="line">* libiconv.dylib</span><br></pre></td></tr></tbody></table></figure>

<p>添加测试代码,根据编译结果添加对应的系统库</p>
<figure class="highlight swift"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">ViewController</span>: <span class="title">UIViewController</span> </span>{</span><br><span class="line"></span><br><span class="line">    <span class="keyword">override</span> <span class="function"><span class="keyword">func</span> <span class="title">viewDidLoad</span>()</span> {</span><br><span class="line">        <span class="keyword">super</span>.viewDidLoad()</span><br><span class="line">        <span class="comment">// Do any additional setup after loading the view.</span></span><br><span class="line">        avdevice_register_all()</span><br><span class="line">        avcodec_configuration()</span><br><span class="line">    }</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure>

<p>错误信息会提示类或者属性无法找到,根据前缀添加系统库,下面是完整的依赖库</p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">AudioToolbox.framework</span><br><span class="line">VideoToolbox.framework</span><br><span class="line">CoreAudio.framework</span><br><span class="line">CoreVideo.framework</span><br><span class="line">AVFoundation.framework</span><br><span class="line">CoreMedia.framework</span><br><span class="line">libz.tbd </span><br><span class="line">ibiconv.tbd</span><br><span class="line">libbz2.tbd</span><br></pre></td></tr></tbody></table></figure>

<p>点击运行,若失败则需检查前面的步骤是否遗漏,亲测有效</p>
<h2 id="集成FFmpeg命令行工具-可选"><a href="#集成FFmpeg命令行工具-可选" class="headerlink" title="集成FFmpeg命令行工具(可选)"></a>集成FFmpeg命令行工具(可选)</h2><p>此步骤可以将我们在终端命令行的<code>ffmpeg</code>命令传入到<code>ffmepg.h</code>的<code>main</code>函数中,可以同通过封装一套统一的协议api,输入参数到<code>main</code>函数中,然后输出文件</p>
<p>向工程中添加<code>ffmpeg</code>工具链main文件相关的类,并加<code>.c</code>文件添加到编译的build phase中</p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">├── cmdutils.c</span><br><span class="line">├── cmdutils.h</span><br><span class="line">├── config.h</span><br><span class="line">├── ffmpeg.c</span><br><span class="line">├── ffmpeg.h</span><br><span class="line">├── ffmpeg_filter.c</span><br><span class="line">├── ffmpeg_opt.c</span><br><span class="line">└── ffmpeg_videotoolbox.c</span><br></pre></td></tr></tbody></table></figure>

<h2 id="集成FFmpeg命令行-CONFIGURE-FLAGS设置"><a href="#集成FFmpeg命令行-CONFIGURE-FLAGS设置" class="headerlink" title="集成FFmpeg命令行-CONFIGURE_FLAGS设置"></a>集成FFmpeg命令行-CONFIGURE_FLAGS设置</h2><p>需要重新编译新的<code>FFmpeg</code>库,将<code>--disable-programs</code> flags关闭,运行通过命令行参数调用.<br>为了解决ffmpeg命令行依赖<code>libpostproc.a</code>库, 需要添加 <code>--enable-gpl</code> flags,网上看了很多博客都没有提到这,最后在全局搜索关键字<code>LICENSE</code>文件中发现了这样一段话</p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">None of</span><br><span class="line">these parts are used by default, you have to explicitly pass `--enable-gpl` to</span><br><span class="line">configure to activate them. In this case, FFmpeg's license changes to GPL v2+.</span><br><span class="line">Specifically, the GPL parts of FFmpeg are:</span><br><span class="line">- libpostproc</span><br><span class="line">...</span><br></pre></td></tr></tbody></table></figure>

<p>大致意识就是如果你需要build这个库文件,需要指定<code>--enable-gpl</code>,但是FFmpeg的license将会变更成<code>GPL v2+</code></p>
<p>最终确认在<code>ffmpeg-build.sh</code>中将<code>CONFIGURE_FLAGS</code>设定为如下选项</p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">CONFIGURE_FLAGS="\</span><br><span class="line">--enable-cross-compile \</span><br><span class="line">--disable-debug \</span><br><span class="line">--enable-gpl \</span><br><span class="line">--disable-doc --enable-pic"</span><br><span class="line"><span class="meta">#</span><span class="bash">--disable-programs \</span></span><br></pre></td></tr></tbody></table></figure>

<p>得出的编译产物如下,相比原来多了一个库<code>libpostproc.a</code></p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">├── include</span><br><span class="line">│   ├── libavcodec</span><br><span class="line">│   ├── libavdevice</span><br><span class="line">│   ├── libavfilter</span><br><span class="line">│   ├── libavformat</span><br><span class="line">│   ├── libavresample</span><br><span class="line">│   ├── libavutil</span><br><span class="line">│   ├── libpostproc</span><br><span class="line">│   ├── libswresample</span><br><span class="line">│   └── libswscale</span><br><span class="line">└── lib</span><br><span class="line">    ├── libavcodec.a</span><br><span class="line">    ├── libavdevice.a</span><br><span class="line">    ├── libavfilter.a</span><br><span class="line">    ├── libavformat.a</span><br><span class="line">    ├── libavresample.a</span><br><span class="line">    ├── libavutil.a</span><br><span class="line">    ├── libpostproc.a</span><br><span class="line">    ├── libswresample.a</span><br><span class="line">    └── libswscale.a</span><br></pre></td></tr></tbody></table></figure>

<h2 id="集成FFmpeg命令行-缺失头文件补充"><a href="#集成FFmpeg命令行-缺失头文件补充" class="headerlink" title="集成FFmpeg命令行-缺失头文件补充"></a>集成FFmpeg命令行-缺失头文件补充</h2><p>集成新的<code>FFmpeg</code>之后运行工程,根据错误提示,按路径添加缺失的头文件<code>.h</code><br>根据如下类似的提示信息在<code>ffmpeg</code>库中搜索头文件并添加到工程中</p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Showing All Messages</span><br><span class="line">/Users/qxq4633/ffmpegdemo/ffmpeg_demo/ffmpeg/ffmpeg.h:22:10: 'config.h' file not found</span><br></pre></td></tr></tbody></table></figure>

<p>最终完整的头文件如下,亲测有效, ffmpeg版本<code>4.3.1</code>,<code>Xcode 12</code>, <code>iOS 14.0</code></p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br></pre></td><td class="code"><pre><span class="line">qxq4633@LSCN897187 ffmpeg_demo % tree -L 4</span><br><span class="line">.</span><br><span class="line">├── FFmpeg-iOS</span><br><span class="line">│&nbsp;&nbsp; ├── include</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; ├── libavcodec</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── ac3_parser.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── adts_parser.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── avcodec.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── avdct.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── avfft.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── bsf.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── codec.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── codec_desc.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── codec_id.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── codec_par.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── d3d11va.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── dirac.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── dv_profile.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── dxva2.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── jni.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── mathops.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── mediacodec.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── packet.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── qsv.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── vaapi.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── vdpau.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── version.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── videotoolbox.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── vorbis_parser.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── x86</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; └── xvmc.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; ├── libavdevice</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── avdevice.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; └── version.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; ├── libavfilter</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── avfilter.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── buffersink.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── buffersrc.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; └── version.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; ├── libavformat</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── avformat.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── avio.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── os_support.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; └── version.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; ├── libavresample</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── avresample.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; └── version.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; ├── libavutil</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── adler32.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── aes.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── aes_ctr.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── attributes.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── audio_fifo.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── avassert.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── avconfig.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── avstring.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── avutil.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── base64.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── blowfish.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── bprint.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── bswap.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── buffer.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── camellia.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── cast5.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── channel_layout.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── common.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── cpu.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── crc.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── des.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── dict.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── display.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── dovi_meta.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── downmix_info.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── encryption_info.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── error.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── eval.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── ffversion.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── fifo.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── file.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── frame.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hash.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hdr_dynamic_metadata.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hmac.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hwcontext.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hwcontext_cuda.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hwcontext_d3d11va.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hwcontext_drm.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hwcontext_dxva2.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hwcontext_mediacodec.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hwcontext_opencl.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hwcontext_qsv.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hwcontext_vaapi.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hwcontext_vdpau.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hwcontext_videotoolbox.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── hwcontext_vulkan.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── imgutils.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── internal.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── intfloat.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── intreadwrite.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── lfg.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── libm.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── log.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── lzo.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── macros.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── mastering_display_metadata.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── mathematics.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── md5.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── mem.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── motion_vector.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── murmur3.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── opt.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── parseutils.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── pixdesc.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── pixelutils.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── pixfmt.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── random_seed.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── rational.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── rc4.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── replaygain.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── reverse.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── ripemd.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── samplefmt.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── sha.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── sha512.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── spherical.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── stereo3d.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── tea.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── thread.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── threadmessage.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── time.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── timecode.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── timestamp.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── tree.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── twofish.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── tx.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── version.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── video_enc_params.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── x86</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; └── xtea.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; ├── libpostproc</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── postprocess.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; └── version.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; ├── libswresample</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; ├── swresample.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; │&nbsp;&nbsp; └── version.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp; └── libswscale</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp;     ├── swscale.h</span><br><span class="line">│&nbsp;&nbsp; │&nbsp;&nbsp;     └── version.h</span><br><span class="line">│&nbsp;&nbsp; └── lib</span><br><span class="line">│&nbsp;&nbsp;     ├── libavcodec.a</span><br><span class="line">│&nbsp;&nbsp;     ├── libavdevice.a</span><br><span class="line">│&nbsp;&nbsp;     ├── libavfilter.a</span><br><span class="line">│&nbsp;&nbsp;     ├── libavformat.a</span><br><span class="line">│&nbsp;&nbsp;     ├── libavresample.a</span><br><span class="line">│&nbsp;&nbsp;     ├── libavutil.a</span><br><span class="line">│&nbsp;&nbsp;     ├── libpostproc.a</span><br><span class="line">│&nbsp;&nbsp;     ├── libswresample.a</span><br><span class="line">│&nbsp;&nbsp;     └── libswscale.a</span><br><span class="line">├── LICENSE</span><br><span class="line">├── README.en.md</span><br><span class="line">├── README.md</span><br><span class="line">├── compat</span><br><span class="line">│&nbsp;&nbsp; └── va_copy.h</span><br><span class="line">├── config.h</span><br><span class="line">├── ffmpeg</span><br><span class="line">│&nbsp;&nbsp; ├── cmdutils.c</span><br><span class="line">│&nbsp;&nbsp; ├── cmdutils.h</span><br><span class="line">│&nbsp;&nbsp; ├── ffmpeg.c</span><br><span class="line">│&nbsp;&nbsp; ├── ffmpeg.h</span><br><span class="line">│&nbsp;&nbsp; ├── ffmpeg_filter.c</span><br><span class="line">│&nbsp;&nbsp; ├── ffmpeg_hw.c</span><br><span class="line">│&nbsp;&nbsp; ├── ffmpeg_opt.c</span><br><span class="line">│&nbsp;&nbsp; └── ffmpeg_videotoolbox.c</span><br></pre></td></tr></tbody></table></figure>

<h2 id="集成FFmpeg命令行-验证ffmpeg输入指令"><a href="#集成FFmpeg命令行-验证ffmpeg输入指令" class="headerlink" title="集成FFmpeg命令行-验证ffmpeg输入指令"></a>集成FFmpeg命令行-验证ffmpeg输入指令</h2><figure class="highlight swift"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">override</span> <span class="function"><span class="keyword">func</span> <span class="title">touchesBegan</span>(<span class="keyword">_</span> <span class="params">touches</span>: <span class="type">Set</span>&lt;<span class="type">UITouch</span>&gt;, <span class="params">with</span> <span class="params">event</span>: <span class="type">UIEvent</span>?)</span> {</span><br><span class="line">        </span><br><span class="line">       <span class="comment">// self.navigationController?.pushViewController(SwiftPointViewController(), animated: true)</span></span><br><span class="line">        <span class="keyword">let</span> inputFile <span class="operator">=</span> <span class="string">"/Users/qxq4633/ffmpegdemo/ffmpeg_demo/ffmpeg_demo/resoures/input.mov"</span>;</span><br><span class="line">      </span><br><span class="line">        <span class="keyword">let</span> outputFilePath <span class="operator">=</span> <span class="string">"/Users/qxq4633/ffmpegdemo/ffmpeg_demo/ffmpeg_demo/resoures/output2.webm"</span>;</span><br><span class="line">        </span><br><span class="line">        <span class="keyword">let</span> arguments <span class="operator">=</span> [ <span class="string">"ffmpeg"</span>,<span class="string">"-i"</span>,inputFile]</span><br><span class="line">        <span class="keyword">let</span> arr <span class="operator">=</span> <span class="type">UnsafeMutablePointer</span>&lt;<span class="type">UnsafeMutablePointer</span>&lt;<span class="type">Int8</span>&gt;?&gt;.allocate(capacity: arguments.count)</span><br><span class="line">        </span><br><span class="line">        <span class="keyword">for</span> index <span class="keyword">in</span> <span class="number">0</span><span class="operator">..&lt;</span>arguments.count {</span><br><span class="line">            arr[index] <span class="operator">=</span> <span class="type">UnsafeMutablePointer</span>&lt;<span class="type">Int8</span>&gt;.<span class="keyword">init</span>(mutating: (arguments[index] <span class="keyword">as</span> <span class="type">NSString</span>).utf8String)</span><br><span class="line">        }</span><br><span class="line">        <span class="built_in">print</span>(<span class="string">"======== start call ffmpeg async ========"</span>)</span><br><span class="line">        <span class="type">DispatchQueue</span>.global().async {</span><br><span class="line">            <span class="built_in">print</span>(<span class="string">"======== ffmpeg_main start ========"</span>)</span><br><span class="line">            ffmpeg_main(<span class="type">Int32</span>(arguments.count), arr)</span><br><span class="line">            <span class="built_in">print</span>(<span class="string">"======== ffmpeg_main end and call back result ========"</span>)</span><br><span class="line">        }</span><br><span class="line">        <span class="built_in">print</span>(<span class="string">"======== handler other logic ========"</span>)</span><br><span class="line">       </span><br><span class="line">    }</span><br></pre></td></tr></tbody></table></figure>

<h2 id="集成FFmpeg命令行-exit-program相关bug修复"><a href="#集成FFmpeg命令行-exit-program相关bug修复" class="headerlink" title="集成FFmpeg命令行-exit_program相关bug修复"></a>集成FFmpeg命令行-exit_program相关bug修复</h2><p>在运行中碰到诸多错误,由于<code>exit_program</code>函数推出时会卡住当前线程，所以需要将此函数设置返回值</p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">int exit_program(int ret)</span><br><span class="line">{</span><br><span class="line">//    if (program_exit)</span><br><span class="line">//        program_exit(ret);</span><br><span class="line"></span><br><span class="line">    //exit(ret);</span><br><span class="line">    return  ret; //TODO: fix thread  not exit</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure>

<p>退出时需要释放野指针</p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">ffmpeg_exited = 1;</span><br><span class="line"> //TODO: fix unsafe pointee</span><br><span class="line"> ffmpeg_exited = 1;</span><br><span class="line"> nb_filtergraphs = 0;</span><br><span class="line"> nb_output_files = 0;</span><br><span class="line"> nb_output_streams = 0;</span><br><span class="line"> nb_input_files = 0;</span><br><span class="line"> nb_input_streams = 0;</span><br></pre></td></tr></tbody></table></figure>

<p>我这个例子是打印文件信息的,没有指定output,默认的print函数会检查输出文件,需要修改此处崩溃</p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time) { ...</span><br><span class="line">  //TODO: Fix out put files not assiged</span><br><span class="line">    if (output_files == NULL){</span><br><span class="line">        return;</span><br><span class="line">    }</span><br></pre></td></tr></tbody></table></figure>

<p>由于我们强制修改退出条件,在overrite文件时需要提前做清除</p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">static void assert_file_overwrite(const char *filename)</span><br><span class="line">{</span><br><span class="line">    </span><br><span class="line">    avpriv_io_delete(filename); //TODO: fix frozen</span><br></pre></td></tr></tbody></table></figure>

<p>这里也设置到返回值没有设定,需要增加返回值</p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">static int opt_init_hw_device(void *optctx, const char *opt, const char *arg)</span><br><span class="line">{</span><br><span class="line">    if (!strcmp(arg, "list")) {</span><br><span class="line">        enum AVHWDeviceType type = AV_HWDEVICE_TYPE_NONE;</span><br><span class="line">        printf("Supported hardware device types:\n");</span><br><span class="line">        while ((type = av_hwdevice_iterate_types(type)) !=</span><br><span class="line">               AV_HWDEVICE_TYPE_NONE)</span><br><span class="line">            printf("%s\n", av_hwdevice_get_type_name(type));</span><br><span class="line">        printf("\n");</span><br><span class="line">        return exit_program(0); //TODO: fix none return</span><br><span class="line">    } else {</span><br><span class="line">        return hw_device_init_from_string(arg, NULL);</span><br><span class="line">    }</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure>

<p>以上就是通过Xcode执行<code>ffmpeg -i input.mov</code> 查看文件信息的全过程</p>
<h2 id="集成FFmpeg命令行-执行顺序"><a href="#集成FFmpeg命令行-执行顺序" class="headerlink" title="集成FFmpeg命令行-执行顺序"></a>集成FFmpeg命令行-执行顺序</h2><p>控制台打印结果如下,在同一个线程中可以看到<code>ffmpeg_main</code>函数是同步执行的. 所以基于此方法我们可以封装一套ffmpeg的命令行接口<br>流程如下:</p>
<p><code>prepare arguments</code> -&gt; <code>call ffmpeg_main async</code> -&gt; <code>return ffmpeg result</code></p>
<p>实际的打印结果也验证了这一点</p>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">======== start call ffmpeg async ========</span><br><span class="line">======== handler other logic ========</span><br><span class="line">======== ffmpeg_main start ========</span><br><span class="line">ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers</span><br><span class="line">  built with Apple clang version 12.0.0 (clang-1200.0.31.1)</span><br><span class="line">  configuration: --prefix=FFmpeg --disable-shared --enable-static --disable-x86asm</span><br><span class="line">  WARNING: library configuration mismatch</span><br><span class="line">  avutil      configuration: --target-os=darwin --arch=x86_64 --cc='xcrun -sdk iphonesimulator clang' --as='gas-preprocessor.pl -- xcrun -sdk iphonesimulator clang' --enable-cross-compile --disable-debug --enable-gpl --disable-doc --enable-pic --extra-cflags='-arch x86_64 -mios-simulator-version-min=8.0' --extra-ldflags='-arch x86_64 -mios-simulator-version-min=8.0' --prefix=/Users/qxq4633/ffmpegdemo/FFmpeg-iOS-build-script/thin/x86_64</span><br><span class="line">  avcodec     configuration: --target-os=darwin --arch=x86_64 --cc='xcrun -sdk iphonesimulator clang' --as='gas-preprocessor.pl -- xcrun -sdk iphonesimulator clang' --enable-cross-compile --disable-debug --enable-gpl --disable-doc --enable-pic --extra-cflags='-arch x86_64 -mios-simulator-version-min=8.0' --extra-ldflags='-arch x86_64 -mios-simulator-version-min=8.0' --prefix=/Users/qxq4633/ffmpegdemo/FFmpeg-iOS-build-script/thin/x86_64</span><br><span class="line">  avformat    configuration: --target-os=darwin --arch=x86_64 --cc='xcrun -sdk iphonesimulator clang' --as='gas-preprocessor.pl -- xcrun -sdk iphonesimulator clang' --enable-cross-compile --disable-debug --enable-gpl --disable-doc --enable-pic --extra-cflags='-arch x86_64 -mios-simulator-version-min=8.0' --extra-ldflags='-arch x86_64 -mios-simulator-version-min=8.0' --prefix=/Users/qxq4633/ffmpegdemo/FFmpeg-iOS-build-script/thin/x86_64</span><br><span class="line">  avdevice    configuration: --target-os=darwin --arch=x86_64 --cc='xcrun -sdk iphonesimulator clang' --as='gas-preprocessor.pl -- xcrun -sdk iphonesimulator clang' --enable-cross-compile --disable-debug --enable-gpl --disable-doc --enable-pic --extra-cflags='-arch x86_64 -mios-simulator-version-min=8.0' --extra-ldflags='-arch x86_64 -mios-simulator-version-min=8.0' --prefix=/Users/qxq4633/ffmpegdemo/FFmpeg-iOS-build-script/thin/x86_64</span><br><span class="line">  avfilter    configuration: --target-os=darwin --arch=x86_64 --cc='xcrun -sdk iphonesimulator clang' --as='gas-preprocessor.pl -- xcrun -sdk iphonesimulator clang' --enable-cross-compile --disable-debug --enable-gpl --disable-doc --enable-pic --extra-cflags='-arch x86_64 -mios-simulator-version-min=8.0' --extra-ldflags='-arch x86_64 -mios-simulator-version-min=8.0' --prefix=/Users/qxq4633/ffmpegdemo/FFmpeg-iOS-build-script/thin/x86_64</span><br><span class="line">  swscale     configuration: --target-os=darwin --arch=x86_64 --cc='xcrun -sdk iphonesimulator clang' --as='gas-preprocessor.pl -- xcrun -sdk iphonesimulator clang' --enable-cross-compile --disable-debug --enable-gpl --disable-doc --enable-pic --extra-cflags='-arch x86_64 -mios-simulator-version-min=8.0' --extra-ldflags='-arch x86_64 -mios-simulator-version-min=8.0' --prefix=/Users/qxq4633/ffmpegdemo/FFmpeg-iOS-build-script/thin/x86_64</span><br><span class="line">  swresample  configuration: --target-os=darwin --arch=x86_64 --cc='xcrun -sdk iphonesimulator clang' --as='gas-preprocessor.pl -- xcrun -sdk iphonesimulator clang' --enable-cross-compile --disable-debug --enable-gpl --disable-doc --enable-pic --extra-cflags='-arch x86_64 -mios-simulator-version-min=8.0' --extra-ldflags='-arch x86_64 -mios-simulator-version-min=8.0' --prefix=/Users/qxq4633/ffmpegdemo/FFmpeg-iOS-build-script/thin/x86_64</span><br><span class="line">  libavutil      56. 51.100 / 56. 51.100</span><br><span class="line">  libavcodec     58. 91.100 / 58. 91.100</span><br><span class="line">  libavformat    58. 45.100 / 58. 45.100</span><br><span class="line">  libavdevice    58. 10.100 / 58. 10.100</span><br><span class="line">  libavfilter     7. 85.100 /  7. 85.100</span><br><span class="line">  libswscale      5.  7.100 /  5.  7.100</span><br><span class="line">  libswresample   3.  7.100 /  3.  7.100</span><br><span class="line">Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/qxq4633/ffmpegdemo/ffmpeg_demo/ffmpeg_demo/resoures/input.mov':</span><br><span class="line">  Metadata:</span><br><span class="line">    major_brand     : qt  </span><br><span class="line">    minor_version   : 0</span><br><span class="line">    compatible_brands: qt  </span><br><span class="line">    creation_time   : 2021-02-05T02:51:34.000000Z</span><br><span class="line">    com.apple.quicktime.make: Apple</span><br><span class="line">    com.apple.quicktime.model: MacBookPro15,1</span><br><span class="line">    com.apple.quicktime.software: Mac OS X 10.15.6 (19G2021)</span><br><span class="line">    com.apple.quicktime.creationdate: 2021-02-05T10:50:55+0800</span><br><span class="line">  Duration: 00:00:26.63, start: 0.000000, bitrate: 2028 kb/s</span><br><span class="line">    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 766x1334 [SAR 1:1 DAR 383:667], 2015 kb/s, 59.93 fps, 60 tbr, 6k tbn, 12k tbc (default)</span><br><span class="line">    Metadata:</span><br><span class="line">      creation_time   : 2021-02-05T02:51:34.000000Z</span><br><span class="line">      handler_name    : Core Media Video</span><br><span class="line">      encoder         : H.264</span><br><span class="line">At least one output file must be specified</span><br><span class="line">Stream mapping:</span><br><span class="line">Press [q] to stop, [?] for help</span><br><span class="line">======== ffmpeg_main end and call back result ========</span><br></pre></td></tr></tbody></table></figure>

<h2 id="代码地址"><a href="#代码地址" class="headerlink" title="代码地址"></a>代码地址</h2><ul>
<li><p>repo: <a target="_blank" rel="noopener" href="https://gitee.com/jiodg45/ffmpeg_demo.git">https://gitee.com/jiodg45/ffmpeg_demo.git</a></p>
</li>
<li><p>feature/add-ffmpeg-command-tool: 包含ffmpeg命令行工具集成</p>
</li>
<li><p>master: normal版本,不包含ffmpeg命令行工具集成</p>
</li>
</ul>
<h2 id="参考文章"><a href="#参考文章" class="headerlink" title="参考文章"></a>参考文章</h2><p><a target="_blank" rel="noopener" href="https://github.com/FFmpeg/FFmpeg.git">FFmpeg</a><br><a target="_blank" rel="noopener" href="https://github.com/tanersener/flutter-ffmpeg.git">FFmpeg-flutter</a><br><a target="_blank" rel="noopener" href="https://github.com/kewlbear/FFmpeg-iOS-build-script.git">FFmpeg-iOS-Scripts</a><br><a target="_blank" rel="noopener" href="https://blog.csdn.net/wenzfcsdn/article/details/84847534">在iOS中使用FFmpeg命令</a></p>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        jiodg45:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/jiodg45/about" rel="external nofollow noreferrer">Longxiang.guo</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://jiodg45.gitee.io/jiodg45/jiodg45/2021/03/11/audio-visual/ffmpeg-2/">https://jiodg45.gitee.io/jiodg45/jiodg45/2021/03/11/audio-visual/ffmpeg-2/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/jiodg45/about" target="_blank">Longxiang.guo</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/jiodg45/tags/audio/">
                                    <span class="chip bg-color">audio</span>
                                </a>
                            
                                <a href="/jiodg45/tags/ffmpeg/">
                                    <span class="chip bg-color">ffmpeg</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/jiodg45/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/jiodg45/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
        </div>
    </div>

    

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/jiodg45/2021/03/16/ios/ios-review/">
                    <div class="card-image">
                        
                        
                        <img src="/jiodg45/medias/featureimages/0.jpg" class="responsive-img" alt="">
                        
                        <span class="card-title"></span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2021-03-16
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            Longxiang.Guo
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/jiodg45/2021/03/11/flutter/flutter-module/">
                    <div class="card-image">
                        
                        
                        <img src="/jiodg45/medias/featureimages/21.jpg" class="responsive-img" alt="Flutter混合栈">
                        
                        <span class="card-title">Flutter混合栈</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            Flutter混合栈
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-03-11
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/jiodg45/categories/flutter/" class="post-category">
                                    flutter
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/jiodg45/tags/flutter/">
                        <span class="chip bg-color">flutter</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/jiodg45/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/jiodg45/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/jiodg45/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/jiodg45/libs/codeBlock/codeShrink.js"></script>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/jiodg45/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/jiodg45/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        display: none;
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        display: none;
        
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/jiodg45/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2019-2021</span>
            
            <span id="year">2019</span>
            <a href="/jiodg45/about" target="_blank">Longxiang.Guo</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/LongXiangGuo" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:290657563@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=290657563" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 290657563" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/jiodg45/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/jiodg45/libs/materialize/materialize.min.js"></script>
    <script src="/jiodg45/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/jiodg45/libs/aos/aos.js"></script>
    <script src="/jiodg45/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/jiodg45/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/jiodg45/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/jiodg45/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/jiodg45/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    <!--腾讯兔小巢-->
    
    

    

    

    
    <script src="/jiodg45/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
